using UnityEngine;

public class carDamageEnemy : MonoBehaviour
{
	private EntityBehavior carScript;

	private void Awake()
	{
		carScript = GetComponent<EntityBehavior>();
	}

	private void OnTriggerEnter(Collider other)
	{
		if (!carScript.enabled)
		{
			return;
		}
		string text;
		if (settings.offlineMode)
		{
			text = other.gameObject.tag;
			if (!text.Equals("CarHitCollider") || !(carScript.GetCurrentSpeed() > settings.speedCarForIgnoreEnemy))
			{
				return;
			}
			EnemyBehavior componentInParent = other.gameObject.GetComponentInParent<EnemyBehavior>();
			if (!componentInParent)
			{
				return;
			}
			if (carScript.GetCurrentSpeed() < settings.speedCarForHighDemageEnemy)
			{
				if (!(carScript.GetCurrentSpeed() > 1f))
				{
					return;
				}
				if (carScript.carWithWeapon)
				{
					if (carScript.privateCar)
					{
						componentInParent.lowDamageCar(150);
					}
					else
					{
						componentInParent.lowDamageCar(75);
					}
				}
				else
				{
					componentInParent.lowDamageCar(35);
				}
			}
			else
			{
				componentInParent.highDamageCar(10000);
			}
			return;
		}
		text = other.gameObject.tag;
		if (!text.Equals("CarHitCollider"))
		{
			return;
		}
		if (BCWDebug.isDebugBuild)
		{
			BCWDebug.Log("CspeedCar " + settings.speedCarForIgnoreEnemy + " vp.GetCurrentSpeed()" + carScript.GetCurrentSpeed());
		}
		if (!(carScript.GetCurrentSpeed() > settings.speedCarForIgnoreEnemy))
		{
			return;
		}
		PlayerBehavior componentInParent2 = other.GetComponentInParent<PlayerBehavior>();
		if (componentInParent2 == null || (TDMController.isTeamGameType && componentInParent2.localTeam == TDMController.myTeam))
		{
			return;
		}
		if (carScript.GetCurrentSpeed() < settings.speedCarForHighDemageEnemy)
		{
			if (carScript.GetCurrentSpeed() > 1f)
			{
				int num = ((!carScript.carWithWeapon) ? 35 : ((!carScript.privateCar) ? 75 : 150));
				componentInParent2.photonView.RPC("DamageCar", PhotonTargets.All, num, carScript.ownerViewId, true);
			}
		}
		else
		{
			componentInParent2.photonView.RPC("DamageCar", PhotonTargets.All, 10000, carScript.ownerViewId, false);
		}
		GameController.instance.playerScript.SetPlayerLastDamageInfo(componentInParent2.GetComponent<Mortal>(), false);
		componentInParent2.lastDamageInfo.weaponType = carScript.weaponType;
	}
}
